package com.snopy.controller.center;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

/**
 * @author snopy
 * @version 1.0.0
 * @classname RedisCacheController
 * @description
 * @email 77912204@qq.com
 * @date 2020/11/23 23:35
 */
@RestController
@RequestMapping("redis")
public class RedisCacheController {

    @Autowired
    private RedisTemplate redisTemplate;

    @PostMapping("/set")
    public void set(@PathParam("key") String key, @PathParam("val")String val){
        redisTemplate.opsForValue().set(key,val);
    }
    @PostMapping("/get")
    @ResponseBody
    public String get(@PathParam("key") String key){

        return (String)redisTemplate.opsForValue().get(key);
    }
}
